package org.chen.bossTimer.response;

public class ResultData<T> {
	private int status;
	private String message;
	private T result;
	private long timestamp;

	private ResultData() {
		this.timestamp = System.currentTimeMillis();
	}

	public static <T> ResultData<T> success(T data) {
		ResultData<T> resultData = new ResultData<>();
		resultData.setStatus(200);
		resultData.setMessage("操作成功");
		resultData.setResult(data);
		return resultData;
	}

	public T getResult() {
		return result;
	}

	public void setResult(T result) {
		this.result = result;
	}

	public static <T> ResultData<T> fail(int code, String message) {
		ResultData<T> resultData = new ResultData<>();
		resultData.setStatus(code);
		resultData.setMessage(message);
		return resultData;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public long getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(long timestamp) {
		this.timestamp = timestamp;
	}

}
